Skip to main content
Phong Nguyễn
💬
0 discussions

Command Service


Command Service is a combination of 3 services:

Customer Service is a service that manipulate database and can be accessed by Gateway via REST API. This service stores customer information such as phone number, customer information, activities on the system.

User Service is one of a service that manipulate database and can be accessed by Gateway via REST API. This service stores user data, role data, sip account

Third party service is a service that manages the integration information of external systems and provides these integration information for the integration service to execute

It only communicates with the access-service. A username and a password, exemplifying Basic Access Authentication, must be validated.

I. Functionality

  • Create, store, and manipulate customer-service database
    • Create, store, and manipulate Activity: calllog, send sms,...
    • Create, store, and manipulate ContactGroup: Contact information in a group
    • Create, store, and manipulate Contact: Information of contact
  • Create, store, and manipulate user-service database
    • Agent: this is where the user's information is stored in a callcenter
    • Role: By default, there are two roles: admin and agent. In addition, you can customize the role yourself
    • SipAccount: Save information about sip account from provider
  • Create, store, and manipulate third-party-service database
    • Create, store, and manipulate Integration Template
    • Create, store, and manipulate Integration Endpoint
    • Create, store, and manipulate Integrator
  • Authorize via a username and a password, exemplifying Basic Access Authentication

II. Packages

1. Dependencies

  • Express - Node.js web application framework: Express
  • MongoDB - Node.js Driver: MongoDB
  • Dotenv - Storing configuration: Dotenv
  • Body-parser - Node.js body parsing middleware: Body-parser
  • Winston - A multi-transport async logging library for node.js: Winston
  • Winston-daily-rotate-file - A transport for winston which logs to a rotating file each day: Winston-daily-rotate-file
  • Morgan - HTTP request logger middleware for node.js: Morgan
  • Bluebird - A full featured promise library with unmatched performance: Bluebird

2. Dev Dependencies

  • Mocha - The fun, simple, flexible JavaScript test framework: Mocha
  • Chai - Assertion library for node: Chai
  • Chai as Promised - Chai assertions for promises: Chai Promised
  • Chai HTTP - HTTP Response assertions for the Chai Assertion Library: Chai HTTP
  • Istanbul - A JavaScript test coverage tool: Istanbul
  • Nyc - Istanbul's state of the art command line interface: Nyc
  • ESLint - The pluggable linting utility for JavaScript and JSX: EsLint

III. Database

1. ERD

  • ERD customer-service

ERD customer-service

  • ERD user-service

ERD user-service

  • ERD third-party-service

ERD third-party-service

2. Database schema

Activity

Activity of an agent goes along with a contact. Indeed, every call center has a distinct collection to store their call logs. The collection names follow the format activity_idCallcenter

FieldTypeDescription
_idstringUnique identity string
creatorstring_id of the agent creating the activity
idContactstring_id of the contact involved
textstringDescription of the activity
typestringThree accepted values of activity category are note, calllog, and reminder
bodyobjectIf type is calllog, body includes idCalllog, status, duration, direction, source, destination, start, and end. If type is reminder, body includes remindedAgent, duedate, and status
body.statusstringIf type is calllog, five accepted values are success, missed, rejected, busy, and connected. If type is reminder, two accepted values are checked and unchecked
body.idCalllogstring_id of the call
body.durationnumberLength of call, measured in seconds
body.directionstringDirection of the call, two accepted values are incoming and outgoing
body.sourcestringCaller of the call
body.destinationstringRecipient of the call
body.startnumberTimestamp of the call initiation, in number of milliseconds since Unix epoch
body.endnumberTimestamp of the call end, in number of milliseconds since Unix epoch
body.remindedAgentstring_id of agent reminded
body.duedatenumberTimestamp of the deadline on schedule, in number of milliseconds since Unix epoch
createdAtint64Timestamp of the document creation, in number of milliseconds since Unix epoch
updatedAtint64Timestamp of the last update, in number of milliseconds since Unix epoch
deletedbooleanStatus of visibility

ContactGroup

ContactGroup provides information about a group of contacts chosen by an agent individually in their view. Indeed, every call center has a distinct collection to store their groups. The collection names follow the format contactGroup_idCallcenter

FieldTypeDescription
_idstringUnique identity string
namestringName of the group
descriptionstringDescription of the group
creatorstring_id of the agent creating the group
contactListarrayEach item is the _id of agent in the group
createdAtint64Timestamp of the document creation, in number of milliseconds since Unix epoch
updatedAtint64Timestamp of the last update, in number of milliseconds since Unix epoch
deletedbooleanStatus of visibility

Contact

Contact provides information of a contact. Indeed, every call center has a distinct collection to store their contacts. The collection names follow the format contact_idCallcenter

FieldTypeDescription
_idstringUnique identity string
firstNamestringFirst name of the contact
lastNamestringLast name of the contact
genderstringGender of the contact
emailstringEmail of the contact
phonestringPhone number of the contact
avatarstringAvatar of the contact
createdAtint64Timestamp of the document creation, in number of milliseconds since Unix epoch
updatedAtint64Timestamp of the last update, in number of milliseconds since Unix epoch
deletedbooleanStatus of visibility

Agent

Agent is a person who works for a call center. Indeed, every call center has a distinct collection to store their agents. The table name follows the format agent_idCallcenter

FieldTypeDescription
_idstringUnique identity string
rolestringRole assigned to the agent, two accepted values are admin and agent
idSipstring_id of SIP account assigned to the agent
createdAtint64Timestamp of the document creation, in number of milliseconds since Unix epoch
updatedAtint64Timestamp of the last update, in number of milliseconds since Unix epoch
deletedbooleanStatus of visibility

Role

Role is assigned to each agent to determine their authorization. Indeed, every call center has a distinct table to store their roles. The table name follows the format role_idCallcenter

FieldTypeDescription
_idstringUnique identity string
namestringName of the role, two accepted values are admin and agent
createdAtint64Timestamp of the document creation, in number of milliseconds since Unix epoch
updatedAtint64Timestamp of the last update, in number of milliseconds since Unix epoch
deletedbooleanStatus of visibility

SipAccount

A SipAccount provides authentication credentials to log in a SIP account. Indeed, every call center has a distinct table to store their SIP accounts. The table name follows the format sipAccount_idCallcenter

FieldTypeDescription
_idstringUnique identity string, in this case, the hotline number
domainstringDomain of the SIP account
extensionstringNumber of extension in SIP URI
passwordstringPassword to get access to call connection
proxystringProxy the of SIP account
createdAtint64Timestamp of the document creation, in number of milliseconds since Unix epoch
updatedAtint64Timestamp of the last update, in number of milliseconds since Unix epoch
deletedbooleanStatus of visibility

ClickToCall

ClickToCall includes information about customized Gcall button of call centers. Each call center only has one click-to-call button

FieldTypeDescription
_idstringUnique identity string
idCallcenterstring_id of the call center
headerstringHeader of the button
contentstringBody description of the button
colorstringColor of the button
positionstringPosition of the button, five accepted values are bottom-left, bottom-right, bottom-center, left-center, and right-center
delaynumberNumber of seconds between loading the button and releasing it
activatedbooleanStatus of the button
deletedbooleanRemoval status of the record
createdAtint64Timestamp of the document creation, in number of milliseconds since Unix epoch
updatedAtint64Timestamp of the last update, in number of milliseconds since Unix epoch
deletedbooleanStatus of visibility

SipProvider

SipProvider provides information about providers that supply SIP accounts

FieldTypeDescription
_idstringUnique identity string
namestringName of the provider
phonestringPhone number of the provider
phoneListarrayList of phone numbers provided, each is a string
tollCoststringToll cost of using the provider's service
firmstringFirm name of the provider
innerCoststringInner cost of using the provider's service
outerCoststringOuter cost of using the provider's service
serviceCoststringInstallmen cost of using the provider's service
deletedbooleanRemoval status of the record
createdAtint64Timestamp of the document creation, in number of milliseconds since Unix epoch
updatedAtint64Timestamp of the last update, in number of milliseconds since Unix epoch
deletedbooleanStatus of visibility

III. Source tree

https://gitlab.com/gcalls/publics/gcallsback/-/tree/Test/commandService

IV. Installation


  • Clone project:
git clone https://gitlab.com/gcalls/publics/gcallsback
  • Change dir into commandService folder
cd commandService
  • Install packages:
npm install
  • Start service:

    • run in development

      npm run dev
    • run in production

      npm install -g pm2
      npm start
  • Test:

    npm run test

V. Endpoint


Please visit API documentation for more details